package 第六章.e3;

import javax.swing.text.html.HTMLDocument;
import java.util.Iterator;
import java.util.LinkedList;

public class E3 {
    public static void main(String[] args) {
        //迭代器Iterator
        LinkedList list = new LinkedList();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add("赵六");
        Iterator it=list.iterator();//返回一个list对象的迭代器
        while(it.hasNext()){
            Object obj=it.next();
            System.out.println(obj);
        }
        System.out.println("for循环迭代集合");

        for (Object obj:list){
            System.out.println(obj);
        }
    }
}
